<template>
	<view class="type-container">
		<u-navbar bgColor="#fff" :placeholder="true" :fixed="true" @leftClick="$back" title="帮助反馈" titleStyle="{'color': '#000'}">
			
		</u-navbar>
		<view class="reply-card">
			<view class="question">
				{{detail.title || ''}}
			</view>
			<view class="answer">
				<rich-text :nodes="detail.content"></rich-text>
				<!-- {{detail.content || ''}} -->
			</view>
		</view>

		<view class="eval display-flex" v-if="showRank">
			<text class="line-l"></text>
			<view>您对答案回复满意么</view>
			<text class="line-r"></text>
		</view>
		<view class="display-flex" style="justify-content: center;" v-if="showRank">
			<view class="emoji" v-for="(it,ix) in emojiList" :key="ix" @tap="onEval(ix)">
				<image :src="it.icon | formatImgUrl" mode="aspectFit"></image>
				<text>{{it.text}}</text>
			</view>
		</view>

		<view class="dibu">
			<view class="dili" @click="$go('/showcase/user/feedback')">
				<image :src="'/images/yijian.png' | formatImgUrl" class="dipic" mode=""></image>
				<view class="fatxt">
					意见反馈
				</view>
			</view>
			<view class="borderline">

			</view>
			<view class="dilv" @tap="onPhone">
				<image :src="'/images/zixun.png' | formatImgUrl" class="dipic" mode=""></image>
				<view class="quetxt">
					电话咨询
				</view>
			</view>
		</view>

		<!-- app 电话咨询弹窗 -->
		<u-popup mode="center" :show="show">
			<view class="link-box">
				<view class="link-cont">
					<view class="title">
						电话咨询
					</view>
					<view class="sub-tit">
						请通过以下方式联系我们
					</view>
					<view class="display-flex" @tap="makeCall(info.mobile1)">
						<text class="label">客服热线1：</text>
						<text class="val">{{info.mobile1 || ''}}</text>
					</view>
					<view class="display-flex" @tap="makeCall(info.mobile2)">
						<text class="label">客服热线2：</text>
						<text class="val">{{info.mobile2 || ''}}</text>
					</view>
					<view class="display-flex" @tap="copy(info.email)">
						<text class="label">官方邮箱：</text>
						<text class="val">{{info.email || ''}}</text>
					</view>
					<view class="display-flex" @tap="copy(info.wx_gz)">
						<text class="label">微信公众号：</text>
						<text class="val">{{info.wx_gz || ''}}</text>
					</view>
					<view class="display-flex">
						<text class="label">咨询时间：</text>
						<text class="val" style="color: #3D3D3D;">{{info.consult}}</text>
					</view>
					<view class="tips">
						<view class="">
							更多消息可关注微信公众号了解
						</view>
						<view class="">
							通过微信小程序点击在线咨询可直接与平台客服进行反馈
						</view>
					</view>
				</view>

				<image :src="'/images/close.png' | formatImgUrl" @click="show = false" class="closepic"
					mode="aspectFit"></image>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				emojiList: [{
					icon: '/images/emoji01.png',
					text: '很不满'
				}, {
					icon: '/images/emoji02.png',
					text: '不满'
				}, {
					icon: '/images/emoji03.png',
					text: '一般'
				}, {
					icon: '/images/emoji04.png',
					text: '满意'
				}, {
					icon: '/images/emoji05.png',
					text: '很满意'
				}],
				info: {},
				showRank: true,
				info: {},
				detail: {}
			}
		},
		onLoad(e) {
			this.id = e.id || ''
			
			this.getInfo()
			
			// #ifdef APP-PLUS
			this.getLink()
			// #endif
		},
		methods: {
			getLink(){
				this.$api.default.request('index/linkType', {}).then((res) => {
					if (res.code) {
						this.info = res.data
					}
				})
			},
			// 评价
			onEval(index){
				this.$api.default.request('user/problemRank', {
					id: this.id,
					rank: index + 1
				}).then((res) => {
					if (res.code == 1) {
						this.$common.successToShow(res.msg, () => {
							this.showRank = false
						})
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			getInfo(){
				this.$api.default.request('index/getproblem', {
					id: this.id
				}).then((res) => {
					if (res.code) {
						this.detail = res.data
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			},
			// 电话咨询
			onPhone() {
				// #ifdef MP-WEIXIN
				wx.openCustomerServiceChat({
					extInfo: {
						url: 'https://work.weixin.qq.com/kfid/kfcf6e13cdfaad774ff'
					},
					corpId: 'wwff81ee3e67679806',
					success(res) {},
					fail(err) {
						console.log('err', err)
					}
				})
				// #endif

				// #ifndef MP-WEIXIN
				this.show = true
				// #endif
			},
			// 拨打电话
			makeCall(tel) {
				uni.makePhoneCall({
					phoneNumber: tel
				})
			},
			// 复制内容
			copy(txt) {
				uni.setClipboardData({
					data: txt,
					success: function() {
						console.log('success');
					}
				});

				uni.getClipboardData({
					success: function(res) {
						console.log(res.data);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(242, 245, 242, 1);
	}

	.type-container {
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		padding-bottom: calc(var(--window-bottom) + 80px);

		.reply-card {
			padding: 40rpx 20rpx;
			background-color: #fff;
			border-radius: 4px;
			margin-bottom: 60rpx;
		}

		.question {
			font-family: Source Han Sans;
			font-size: 16px;
			font-weight: bold;
			color: #3D3D3D;
			padding-bottom: 24rpx;
			margin-bottom: 24rpx;
			border-bottom: 1px solid #F4F4F4;
		}

		.answer {
			font-family: '思源黑体';
			font-size: 14px;
			color: #3D3D3D;
		}

		.eval {
			justify-content: center;
			margin-bottom: 20px;

			view {
				margin: 0 14px;
				font-family: 思源黑体;
				font-size: 11px;
				color: #3D3D3D;
			}

			text {
				width: 30px;
				height: 2px;
			}

			.line-l {
				background: linear-gradient(to right, rgba(#3D3D3D, 0), rgba(#3D3D3D, 1));
			}

			.line-r {
				background: linear-gradient(to right, rgba(#3D3D3D, 1), rgba(#3D3D3D, 0));
			}
		}

		.emoji {
			margin: 0 17px;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 24px;
				height: 24px;
				margin-bottom: 8rpx;
			}

			text {
				font-family: '思源黑体';
				font-size: 10px;
				color: #3D3D3D;
			}
		}
	}

	.dibu {
		position: fixed;
		background-color: #ffffff;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 100rpx;
		box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.302);
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding-bottom: calc(var(--window-bottom) + 10px);

		.dili {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 330rpx;
			height: 60rpx;
			margin: 0 15rpx;
		}

		.dipic {
			width: 32rpx;
			height: 32rpx;
			margin-right: 16rpx;
		}

		.fatxt,
		.quetxt {
			font-family: Source Han Sans;
			font-size: 14px;
			color: #3D3D3D;
		}

		.borderline {
			width: 1px;
			height: 40rpx;
			background-color: #3D3D3D;
		}

		.dilv {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 330rpx;
			height: 60rpx;
			margin: 0 15rpx;
		}
	}

	.link-box {
		.link-cont {
			width: 267px;
			border-radius: 8px;
			background: #FFFFFF;
			padding: 40rpx 18rpx;
			box-sizing: border-box;
			text-align: center;

			.title {
				font-family: '思源黑体';
				font-size: 16px;
				font-weight: bold;
				color: #3D3D3D;
			}

			.sub-tit {
				margin-top: 6rpx;
				margin-bottom: 30rpx;
				font-family: '思源黑体';
				font-size: 12px;
				color: #999999;
			}

			.display-flex {
				margin-bottom: 26rpx;
				font-family: '思源黑体';
				font-size: 12px;
				color: #3D3D3D;
				justify-content: center;
			}

			.tips {
				font-family: '思源黑体';
				font-size: 10px;
				color: #999999;
			}
			
			.val{
				color: #45C4B0;
			}
		}

		.closepic {
			display: block;
			margin: 0 auto;
			margin-top: 20px;
			width: 24px;
			height: 24px;
		}
	}
</style>